package com.hzjh.h5mall.http

import com.hzjh.base.ext.data.UserDataBean
import com.hzjh.base.http.ApiClient
import com.hzjh.base.http.BaseResponse
import com.hzjh.h5mall.BuildConfig
import com.hzjh.h5mall.bean.wallet.PayInfoBean
import com.hzjh.h5mall.bean.wallet.WalletBean
import com.hzjh.h5mall.bean.wallet.WalletDetailBean
import okhttp3.RequestBody
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.Headers
import retrofit2.http.POST
import retrofit2.http.Path
import retrofit2.http.QueryMap

interface WalletApi {
    //我的钱包
    @Headers("Content-Type: application/json;charset=UTF-8")
    @GET("api/front/user/account/myAccount")
    suspend fun reqMyWallet(@QueryMap request: Map<String, String>): BaseResponse<WalletBean>

    //添加MetaMask
    @Headers("Content-Type: application/json;charset=UTF-8")
    @POST("api/front/user/account/bindMetamask/{metamastNo}")
    suspend fun reqAddMetaMask(@Path("metamastNo") metamastNo: String): BaseResponse<Any>

    //删除MetaMask
    @Headers("Content-Type: application/json;charset=UTF-8")
    @POST("api/front/user/account/delMetamask/{metamastNo}")
    suspend fun reqDelMetaMask(@Path("metamastNo") metamastNo: String): BaseResponse<Any>

    //获取用户信息
    @Headers("Content-Type: application/json;charset=UTF-8")
    @GET("api/front/user/info")
    suspend fun reqUserInfo(@QueryMap request: Map<String, String>): BaseResponse<UserDataBean>

    //获取支付信息
    @Headers("Content-Type: application/json;charset=UTF-8")
    @GET("api/front/login/getQrcode/walletPayQrcode")
    suspend fun reqRechargeQrCode(@QueryMap request: Map<String, String>): BaseResponse<PayInfoBean>

    //提交交易码
    @Headers("Content-Type: application/json;charset=UTF-8")
    @POST("api/front/user/account/pay")
    suspend fun reqAddPayId(@Body request: RequestBody): BaseResponse<String>

    //获取当月提现次数
    @Headers("Content-Type: application/json;charset=UTF-8")
    @GET("api/front/user/account/withdrawNum")
    suspend fun reqWithdrawCount(@QueryMap request: Map<String, String>): BaseResponse<Int>

    //申请提现
    @Headers("Content-Type: application/json;charset=UTF-8")
    @POST("api/front/user/account/withdraw")
    suspend fun reqWithdraw(@Body request: RequestBody): BaseResponse<String>

    //获取账单详情
    @Headers("Content-Type: application/json;charset=UTF-8")
    @GET("api/front/user/account/financialDetails/{id}")
    suspend fun reqWalletDetail(@Path("id") id: String): BaseResponse<WalletDetailBean>

    //获取比特币汇率
    @Headers("Content-Type: application/json;charset=UTF-8")
    @GET("api/front/index/getRate")
    suspend fun reqEthRate(): BaseResponse<String>


    companion object {
        private val api: WalletApi by lazy {
            ApiClient.create(BuildConfig.apiHost,WalletApi::class.java)
        }
        fun create(): WalletApi {
            return api
        }
    }
}